import React from 'react';
import { Switch } from 'antd';
import ProTable from '@ant-design/pro-table';
import Addserveritem from "@/pages/customerService/CustomerServiceList/components/addSeverItem";
import  {ModalForm,} from '@ant-design/pro-form';
import {disManagementPersonList} from "@/services/ant-design-pro/distribution";



const tableListDataSource = [];
const nameArr = ['大强','二强','三强','四强','五强','六强']
for (let i = 0; i < 5; i += 1) {
  tableListDataSource.push({
    key: `${i+1}`,
    weixinname: 'AppName',
    id: Math.floor(Math.random() * 20),
    image: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
    CSname:nameArr[Math.floor(Math.random() * nameArr.length)],
    status:true,
    addtime: '2021-8-31',
  });
}

const columns = [
  {
    title: 'ID',
    // width: 80,
    dataIndex: 'id',
    key:'id'
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    key: 'avatar',
    valueType: 'image',
  },
  {
    title: '用户信息',
    dataIndex: 'useInfo',
    key:'useInfo',
    render:(_,record)=>{
      return(
        <div>
          <div>昵称：{record.nickname}</div>
          <div>姓名：{record.real_name}</div>
          <div>电话：{record.phone}</div>
        </div>
      )
    }
  },
  {
    title: '推广用户数量',
    dataIndex: 'spread_count',
    key:'spread_count'
  },
  {
    title: '订单数量',
    dataIndex: 'promoter_order_count',
    key:'promoter_order_count'
  },
  {
    title: '订单金额',
    dataIndex: 'pay_price',
    key:'pay_price'
  },
  {
    title: '分销等级',
    dataIndex: 'promoter_level',
    key:'promoter_level',
  },
  {
    title: '账户佣金',
    dataIndex: 'brokerage_price',
    key:'brokerage_price',
  },
  {
    title: '已提现金额',
    dataIndex: 'withdraw_amount',
    key:'withdraw_amount',
  },
  {
    title: '提现次数',
    dataIndex: 'userextract_count',
    key:'userextract_count',
  },
  {
    title: '未提现金额',
    dataIndex: 'dis_level22',
    key:'dis_level',
  },
  {
    title: '上级推广人',
    dataIndex: 'dis_level11',
    key:'dis_level',
  },
  {
    title: '操作',
    align:'center',
    valueType: 'option',
    fixed: 'right',
    key: 'option',
    render: () => [
      <ModalForm
        title="工作台"
        trigger={
          <span><a key="link1"> 推广人 </a>  </span>
        }
      >
        <Addserveritem />
      </ModalForm>,

      <ModalForm

        trigger={
          <a key="link3"> 更多 </a>
        }
      >
        <h1>更多功能正在开发，敬请期待</h1>
      </ModalForm>,

    ],
  },
]




const ManagementTable = () => {
  return (
    <div>
      <ProTable
        columns={columns}
        request={async (params, sorter, filter) => {
          // 表单搜索项会从 params 传入，传递给后端接口。
          console.log('这里',params, sorter, filter);
          console.log(tableListDataSource)
          const datas = await disManagementPersonList({})
          console.log('数据',datas);
          return Promise.resolve({
            data: datas.data,
            success: true,
          });
        }}
        rowKey="key"
        pagination={{
          showQuickJumper: true,
        }}
        options={false}
        search={false}
        dateFormatter="string"
        // toolBarRender={()=>[
        //   <LevelTitle/>
        // ]}
      />
    </div>
  );
};

export default ManagementTable;
